# Makefile for libgtcltk
# Copyright (C) 1994 Free Software Foundation, Inc.
# 
# This file is part of GNU Gtcltk
# 
# GNU Gtcltk is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# 
# GNU Gtcltk is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with GNU SED; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
glsdir = $(exec_prefix)/lib/gls
includedir = $(prefix)/include
infodir = $(prefix)/info

#### Start of system configuration section. ####

CC = @CC@
BISON = @YACC@
FLEX = @LEX@
INSTALL = @INSTALL@
DEFS = @DEFS@
CFLAGS = -g -I. -I$(srcdir)/../libguile -I../libguile 
AR = ar
AR_FLAGS = rc
RANLIB = @RANLIB@
source= ctax-lex.l ctax-parse.y ctax.c
xfiles=ctax.x
headers=ctax.h
scm_files=ctax.scm
ancillery=configure.in Makefile.in configure \
	  COPYING ChangeLog \
	ctax.doc \
	  PLUGIN 
distfiles=$(source) $(headers) $(ancillery) $(scm_files)
libobjs=ctax-lex.o ctax-parse.o ctax.o

.SUFFIXES:
.SUFFIXES: .o .c .h .ps .dvi .info .texinfo .scm .cd .x 

.c.x:
	$(CC) $(CFLAGS) -DSCM_MAGIC_SNARFER -E $< | grep "^%%%" | sed -e "s/^%%%//" > $@ ; \

.c.o:
	$(CC) -c $(CFLAGS) $(DEFS) -I$(srcdir) $<

all: libctax.a

install: all
	test -d $(libdir) || mkdir $(libdir)
	test -d $(glsdir) || mkdir $(glsdir)
	test -d $(includedir) || mkdir $(includedir)
	$(INSTALL) libctax.a $(libdir)/libctax.a
	$(RANLIB) $(libdir)/libctax.a
	$(INSTALL) $(srcdir)/ctax.h $(includedir)/ctax.h
	for f in $(scm_files); do \
	  $(INSTALL) $(srcdir)/$$f $(glsdir)/$$f; \
	done


uninstall:
	-rm -f $(libdir)/libctax.a
	-rm -f $(includedir)/ctax.h

clean:
	-rm -f $(libobjs) $(xfiles) libctax.a

distclean: clean
	-rm Makefile config.status

mostlyclean: clean

realclean: distclean

TAGS:
	etags $(source)

info:

install-info:

clean-info:

dvi:

check:

SUBDIR=.
manifest:
	for file in $(distfiles); do echo $(SUBDIR)/$$file; done

dist:	$(distfiles)
	echo ctax-`sed -e '/version_string/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q ctax.c` > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	ln $(distfiles) `cat .fname`
	tar chzf `cat .fname`.tar.gz `cat .fname`
	rm -rf `cat .fname` .fname


libctax.a: $(libobjs)
	rm -f libctax.a
	$(AR) $(AR_FLAGS) libctax.a $(libobjs)
	$(RANLIB) libctax.a

$(srcdir)/ctax-parse.h $(srcdir)/ctax-parse.c: ctax-parse.y
	$(BISON) -d $(srcdir)/ctax-parse.y
	sed -e 's/yy/ctyy/g' y.tab.c > $(srcdir)/ctax-parse.c
	sed -e 's/yy/ctyy/g' y.tab.h > $(srcdir)/ctax-parse.h

ctax-parse.o: $(srcdir)/ctax-parse.c ctax.h

$(srcdir)/ctax-lex.c: ctax-lex.l
	$(FLEX) $(srcdir)/ctax-lex.l
	sed -e 's/yy/ctyy/g' lex.yy.c > $(srcdir)/ctax-lex.c


ctax-lex.o: $(srcdir)/ctax-lex.c ctax.h $(srcdir)/ctax-parse.h
ctax.o: ctax.c ctax.h ctax.x

